import React, { createContext, useContext } from 'react';
import RootStore from '../store/RootStore';

//Root Context which contains all the stores
const RootContext = createContext();

export const RootProvider = ({ children }) => {

  const store = new RootStore();
  
  return (
    <RootContext.Provider value={store}>
      {children}
    </RootContext.Provider>
  );
};

export const useRootStore = () => {
  return useContext(RootContext);
};